/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package za.co.pas.spaceandtime.model.list;

import java.util.List;
import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
import za.co.pas.spaceandtime.constant.STConstant;
import za.co.pas.spaceandtime.data.RoomType;
import za.co.pas.spaceandtime.model.ConfigDataModel;
import za.co.pas.spaceandtime.mvc.SpaceAndTimeMVC;

/**
 *
 * @author alabuschagne
 */
public class RoomTypeListModel implements ListModel
{
    private ConfigDataModel configDataModel = (ConfigDataModel) STConstant.stMVC.getModel(SpaceAndTimeMVC.CONFIG_DATA_MODEL);

    @Override
    public int getSize()
    {
        if(configDataModel != null)
        {
            List<RoomType> rt = configDataModel.getRoomTypes(false);
            if(rt != null)
            {
                return rt.size();
            }
            else
            {
                return 0;
            }
        }
        else
        {
            return 0;
        }
    }

    @Override
    public Object getElementAt(int index)
    {
        if(configDataModel != null)
        {
            List<RoomType> rt = configDataModel.getRoomTypes(false);
            if((rt != null) && (!rt.isEmpty()))
            {
                return rt.get(index);
            }
            else
            {
                return null;
            }
        }
        else
        {
            return null;
        }
    }

    @Override
    public void addListDataListener(ListDataListener l)
    {

    }

    @Override
    public void removeListDataListener(ListDataListener l)
    {

    }
}
